#!/bin/sh
set -e

BUILD="$(pwd)"

USER_OPTS="$@"
if test -f "$BUILD"/mpv_options ; then
    USER_OPTS="$(cat "$BUILD"/mpv_options) $USER_OPTS"
fi
OPTIONS="$USER_OPTS"

case "$PKG_CONFIG_PATH" in
  '')
    export PKG_CONFIG_PATH="$BUILD/build_libs/lib/pkgconfig"
    ;;
  *)
    export PKG_CONFIG_PATH="$BUILD/build_libs/lib/pkgconfig:$PKG_CONFIG_PATH"
    ;;
esac

echo Using mpv options: $OPTIONS

cd "$BUILD"/mpv
./waf configure $OPTIONS
